package com.jiexinyun.exception;

import com.jiexinyun.error.ErrorCode;
import lombok.Data;

@Data
public class BusinessException extends RuntimeException {

    private int code = 500; // 错误码
    private String message; // 错误信息

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.message = errorCode.getMessage();
    }

    public BusinessException(String message) {
        super(message);
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
